<?php

namespace App\Services\WechatApi;

class WechatApiPay extends WechatApiBase
{
    // 查询 虚拟支付2.0 余额
    public function getBalance20($access_token, $signature, $pay_sig, $params)
    {
        $api = "wxa/game/getbalance?access_token={$access_token}&signature={$signature}&pay_sig={$pay_sig}&sig_method=hmac_sha256";
        return $this->send($api, $params, 'post');
    }

    // 查询余额
    // https://developers.weixin.qq.com/minigame/dev/api-backend/midas-payment/midas.getBalance.html
    public function getBalance($url, $access_token, $params)
    {
        $api = "{$url}?access_token={$access_token}";
        return $this->send($api, $params, 'post');
    }

    // 扣除 虚拟支付2.0
    public function subBalance20($access_token, $signature, $pay_sig, $params)
    {
        $api = "wxa/game/pay?access_token={$access_token}&signature={$signature}&pay_sig={$pay_sig}&sig_method=hmac_sha256";
        return $this->send($api, $params, 'post');
    }
}
